<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="/WEB-INF/page-base.tld" prefix="p"%>
<%String path=request.getContextPath(); %>
<script>
function user_adduser(){
	if($getByName("deptman_deptid").val()==''){
		window.parent.$w.infoMsg("请先选择一个机构");
		return false;
	}
	var str=ctx+"/platform/user/UserManagePage.page?actions=addShow&deptId="+$getByName("deptman_deptid").val();
	window.parent.$w.openDialog({url:str,title:'添加用户信息',w:600,h:480,afterClose:function(){
		if(window.parent.$w.listFlesh)
			user_reloadUserList();
		}
	});
	return false;
}
function user_edituser(uid){
	var str=ctx+"/platform/user/UserManagePage.page?actions=updateShow&primaryKey_="+uid;
	window.parent.$w.openDialog({url:str,title:'修改用户信息',w:600,h:480,afterClose:function(){
		if(window.parent.$w.listFlesh)
			user_reloadUserList();
		}
	});
}
function user_deluser(){
	window.parent.$w.confirmMsg("确定删除？", function(r){
		if(r){
			var mform=$w.currForm();
			mform[0].actions.value="del";
			$w.execForm({target:$('#useradminListPanel')});
			}
	});
}
function user_stateUser(state,uid){
	var mform=$w.currForm();
	if(state==0)
		mform[0].actions.value="updateState0";
	else if(state==1)
		mform[0].actions.value="updateState1";
	$("[name='primaryKey_']",$w.currForm()).each(function(){
		if(this.value==uid)
			this.checked=true;
		else
			this.checked=false;
	});
	$w.execForm({target:$('#useradminListPanel')});
}
function user_setrank(uid){
	var str=ctx+"/platform/user/UserManagePage.page?actions=setRankShow&bean.userid="+uid+"&deptId="+$getByName("deptId",$w.currForm()).val();
	window.parent.$w.openDialog({url:str,title:'分配用户权限',w:520,h:480});
}
function user_updatauserPwd(uid){
	var str=ctx+"/platform/user/UserManagePage.page?actions=updatePwdShow&primaryKey_="+uid;
	window.parent.$w.openDialog({url:str,title:'修改用户密码',w:420,h:215});
}
function user_reloadUserList(){
	var mform=$w.currForm();
	$w.execUrl(ctx+mform.attr("action"),mform.serializeArray(),$('#useradminListPanel'));
}
</script>

<form action="/platform/user/UserManagePage.page" method="post">
<p:hidden bind="pageNum"/>
<p:hidden bind="actions"/>
<p:hidden bind="deptId"/>
<p:hidden bind="pageSize_"/>
<div class="easyui-panel ui-queryBar" border="false" data-options="doSize:false">
	<table cellpadding="0" cellspacing="0" style="margin-top:5px">
		<tr>
			<td>&nbsp;查询关键字：</td><td><p:text bind="userName" style="width:300px;"/></td>
			<td>
				&nbsp;<a href="#" class="easyui-linkbutton" iconCls="icon_search" onclick="$w.execForm({target:$('#useradminListPanel')})">查询</a>
			</td>
		</tr>
		</tr>
	</table>
</div>

<div class="easyui-panel ui-toolBar" border="false" data-options="doSize:false">
	<a href="#" class="easyui-linkbutton" iconCls="icon_add" plain="true" onclick="user_adduser()">添加</a>
	<a href="#" class="easyui-linkbutton" iconCls="icon_del" plain="true" onclick="user_deluser()">删除</a>
	
</div>
<div class="ui_line" style="margin-top:10px"></div>
<table class="ui-table" width="100%" cellpadding="1" cellspacing="1" data-options="showPage:true,
																					pageNum:<p:write bind="pageNum"/>,
																					pageSize:<p:write bind="pageSize_"/>,
																					total:<p:write bind="pagination.totalCount"/>,
																					target:'useradminListPanel'">
	<thead>
		<tr class="ui_th">
			<td width="35" align="center"><input type="checkbox" onclick="$selAllTbBoxs(this)"></td>
			<td align="center">账号</td><td align="center">用户名称</td>
   			<td align="center" width="80">注册时间</td><td align="center" width="35">状态</td>
   			<td align="center" width="105">权限与岗位</td><td align="center" width="90">修改密码</td>
   			<td align="center"width="40">修改</td>
		</tr>
	</thead>
	<tbody>
	<p:iterate id="user" bind="resultList_">
		<p:define id="userId" bind="#user.userid"/>
			<tr class="ui_td">
				<td align="center" width="27"><input type="checkbox" name="primaryKey_" value="<%=userId %>"></td>
			    <td align="center"><p:write bind="#user.loginname"/></td><td align="center"><p:write bind="#user.username"/></td>
			    <td align="center"><p:write bind="#user.regTime" format="yyyy-MM-dd"/></td>
			    <td align="center">
			    <p:equal bind="#user.state" value="1"><img src="<%=path %>/platform/images/yes.gif" title="有效，点击冻结用户" style="cursor:pointer" onclick="user_stateUser(0,'<%=userId %>')">
			    </p:equal>
			    <p:equal bind="#user.state" value="0"><img src="<%=path %>/platform/images/no.gif" title="被冻结，点击激活用户" style="cursor:pointer" onclick="user_stateUser(1,'<%=userId %>')">
			    </p:equal>
			    </td>
			    <td align="center"><button onclick="user_setrank('<%=userId %>');return false;">权限与岗位</button></td>
			    <td align="center"><button onclick="user_updatauserPwd('<%=userId %>');return false;">修改密码</button></td>
			    <td><a href="#" onclick="user_edituser('<%=userId %>')" class="data_edit">修改</a></td>
			</tr>
		</p:iterate>
	</tbody>
</table>
</form>